package com.xbongbong.paas.util;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.pro.constant.CommonConstant;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/6/3 10:55
 * @since v1.0
 */
public class LevelUtil {

    public static String getLevelString(String level) {
        String levelString;
        switch (level) {
            case "3":
            case "4":
                levelString = I18nMessageUtil.getMessage(CommonConstant.MEDIUM);
                break;
            case "5":
                levelString = I18nMessageUtil.getMessage(CommonConstant.HIGH);
                break;
            case "1":
            case "2":
                levelString = I18nMessageUtil.getMessage(CommonConstant.LOW);
                break;
            default:
                levelString = "";
                break;
        }
        return levelString;
    }

    public static String transferLevel2Chinese(Integer star) {
        Map<Integer, String> starMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        starMap.put(1, I18nMessageUtil.getMessage(CommonConstant.ONE_STAR));
        starMap.put(2, I18nMessageUtil.getMessage(CommonConstant.TWO_STAR));
        starMap.put(3, I18nMessageUtil.getMessage(CommonConstant.THREE_STAR));
        starMap.put(4, I18nMessageUtil.getMessage(CommonConstant.FOUR_STAR));
        starMap.put(5, I18nMessageUtil.getMessage(CommonConstant.FIVE_STAR));
        return Objects.toString(starMap.get(star), I18nMessageUtil.getMessage(CommonConstant.ZERO_STAR));
    }
}
